<template>
	<div>
		<el-button type="text" @click="dialogVisible=true">新增属性</el-button>
		<el-dialog
			title="新增属性"
			:visible.sync="dialogVisible">
			<el-form label-width="100px" label-position="left">
				<el-form-item label="属性名称">
					<el-input v-model="name"></el-input>
				</el-form-item>
				<el-form-item>
					<el-button @click="commit()">提交</el-button>
				</el-form-item>
			</el-form>
		</el-dialog>
	</div>
</template>

<script>
  import {addProperty} from '@/api/admin/property.js'
	export default{
		data() {
			return {
				dialogVisible:false,
				name:''
			}
		},
    methods: {
      commit() {
        // let data = new FormData()
        // data.append('category',this.$route.query.id)
        // data.append('name',this.name)
		let data = {
			category:this.$route.query.id,
			name:this.name
		}
        addProperty(data).then(res => {
          if(res.code == 200){
            this.$message({
              type:'success',
              message:'添加成功'
            })
            this.dialogVisible = false
            this.$emit('flash')
          }
        })
      }
    },
	}
</script>

<style scoped>
</style>
